let $btn =$("#subReg");
let username =$("#username")
let password = $("#password")
let rpassword = $("#rpassword")
let nickname = $("#nickname")

$btn.click(function(){
     lodo()
    .done(function(data){
         console.log(data);
        //  alert("chneggong")
        if(data.code===1){
            alert("恭喜注册成功,马上为您跳转登录")
            setTimeout(function(){
                location.href = "./denglu.html";
        },1000)
        
        }else{
            alert(data.message)
        }
        
    })
})

function lodo(){
    let options ={
        url:"http://127.0.0.1:8888/users/register",
        type:"POST",
        data:{
             username:`${username[0].value}`,
             password:`${password[0].value}`,
             rpassword:`${rpassword[0].value}`,
             nickname:`${nickname[0].value}`
        },
       datatype:'json'
    }
   
    return $.ajax(options)
    
}

